Opening files and folders


WinMerge provides several ways to specify paths and open files or folders:

1. Select Files or Folders dialog

Quick start describes the Select Files or Folders dialog. This section provides more details, and some tips for using the Select Files or Folders dialog more efficiently.

1.1. Using environment variables

You can use environment variables in your paths. Windows expands the variable name between % (percent) delimiters. For example, if an environment variable named WORKDIR has the value c:\workfiles, then the path %WORKDIR%\project1 is expanded to c:\workfiles\project1 .

1.2. Opening archive files

WinMerge archive support is provided in the 7-Zip plugin. See Getting and installing WinMerge to install this plugin.

Opening two archive files is similar to opening normal files: specify two archive files in the Open-dialog's Left and Right fields. If WinMerge recognizes the archive format, it opens the contents of the archive files in the Folder Compare window.

The Comparing and merging folders topic describes how to work with archive files. For example, if an archive file contains two subfolders named Original/ and Altered/, you can compare the contents of the two subfolders by specifying the same archive file in both sides in the Select Files or Folders dialog or WinMerge command line.

[Tip] Tip

When you drag an archive file to the WinMerge window, press Shift when dropping the file: WinMerge automatically copies the same filename to both sides and opens the archive file.

1.3. Applying filters

The Filter edit field enables you to restrict the files to be included in your folder compare. You can specify one or more file masks, or a single file filter (not both).

A mask is a simple expression based on file extensions. For example, this list of file masks includes only files with the specified extensions; all others are excluded from the selection when the compare operation starts:

*.h;*.cpp *.txt,*.ini

File masks are practical for simple filtering; for more advanced selecting, use filter files. Filter files are collections of regular expressions that can either include or exclude files. WinMerge installs a number of predefined filter files in its Filters folder, and you can create your own, too.

To specify a filter, click the Select button next to the Filters field to choose from a list of available filters. Or, click the Filter drop-down list and choose a recently-used filter file.

For full information about filter masks and filter files, see Using Filters.

1.4. Selecting an unpacker for file comparisons

Unpackers are plugins that are installed with WinMerge to provide functionality that is not used by default. Plugins that can be used to preprocess certain types of files before comparing them. For example, WinMerge cannot normally compare MS Word doc files, but by unpacking them, you can compare just the text contents. See Plugins for details.

To apply a plugin to your file comparison, click the Select button for the Unpacker option. In the Select Unpacker dialog:

  1. Configure automatic plugin selection or choose a plugin manually:

    • To use automatic mode (which applies the first available plugin), verify that <None> is displayed in the the File unpacker control.

    • To choose a different plugin (if available), use the File unpacker control to choose the plugin.

      By default, this control lists only suggested plugins for the file type you selected to compare. To see all available plugins, enable the option, Display all packers, don't check the extension.

    • To launch the compare without using any plugin, choose <None> in the File unpacker control.

  2. Click OK to close the Select Unpacker dialog.

Your choice is displayed in the Unpacker field. Note that you cannot select an unpacker when launching a Folder Compare operation.

2. Shell integration

The Windows shell Integration is a convenient way to select paths and open WinMerge directly from Windows Explorer. It adds a WinMerge shortcut in the Explorer context menu (available when you right-click one or two files or folders in Explorer). For example:

Simple WinMerge context menu

You can enable the shell integration when you install WinMerge. After installing WinMerge, you can enable or disable the shell integration in the System page of the Options dialog.

To use the shell integration, begin by selecting either one or two paths in Windows Explorer:

  • If you select a single path, WinMerge opens the Select Files or Folders dialog. It places the selected file or folder in the Left field, leaving the Right path for you to specify.

  • If you select two files or folders, WinMerge opens them directly in the File Compare or Folder Compare window. However, if one or more paths cannot be opened for any reason, WinMerge opens the Select Files or Folders dialog for you to reselect the paths.

2.1. Advanced shell integration

The advanced shell integration enables you to control the order in which paths are compared when you launch WinMerge from the Windows Explorer context menu. To configure the advanced shell integration, select Enable advanced menu in the System page of WinMerge options.

In the standard shell integration, when you select two paths in Windows Explorer and then right-click and choose WinMerge, the order of comparison in WinMerge is determined by the sort order in Windows Explorer. For example, if your Windows Explorer file list is sorted by name descending, and you select File1 and File2, WinMerge opens with File1 on the left side and File2 on the right. You can change the order only within WinMerge, after it opens.

The advanced shell integration replaces the standard WinMerge shortcut in the Windows Explorer context menu with a set of shortcuts that enable you to control the comparison order before launching WinMerge:

Advanced WinMerge context menu
Compare To

Designates the selected path as the first (Left) path in the comparison. The path is loaded in memory; meanwhile WinMerge waits for you select the second path in Windows Explorer, using the Compare shortcut (described next).

Compare

Designates the selected path as the second (Right) path in the comparison, and opens WinMerge in one of these ways:

  • If you previously designated the first path (using Compare To), WinMerge opens the File Compare or Folder Compare window, and compares the first and second paths you have specified.

  • If you click Compare before designating the first path, the Select Files or Folders dialog is opened, with your selection as the first (Left) path. Specify the second path in the Right field to continue with the comparison.

Re-select First

Available in the context menu only after you apply Compare To. Designates the selected path as the first path, overriding the previous Compare To selection. This is useful, for example, if you accidentally select the wrong first path.

The shell integration paths that you map are stored in memory until you use them to open WinMerge. As a result, you don't need to select both files at the same time or even using the same Windows Explorer view: you can choose one, open a different directory, and choose the other one. Both paths are discarded from memory after a compare operation. This means that you cannot select one Compare To path and compare it against several paths.

Here is a simple method of using the advanced integration נthere are other scenarios, of course. In Windows Explorer:

  1. Right-click the first item you want to compare and choose the Compare To shortcut in the context menu. The path is now in memory.
  2. Locate the second item you want to compare. Right-click the item and choose Compare to launch WinMerge and perform the comparison.

2.2. Including Subfolders

By default, WinMerge does not include subfolders in compare operations. To change the default behavior, enable Include subfolders by default in the System page of WinMerge options. To change include subfolders while using the shell integration, press and hold the Control key while selecting Compare in the Windows Explorer context menu.

3. Drag and drop

From any Windows source that allows you to drag objects, such as Windows Explorer or the Desktop, you can drag and drop one or two paths into the WinMerge window. If you drop only one path into WinMerge, the Select Files or Folders dialog opens for you to select the second path. If the single path specifies a project file, then the project file is opened.

By default, WinMerge does not include subfolders in compare operations. To include subfolders, press and hold Control while dropping paths. Another useful key when dropping paths is Shift: To open the same path in both sides of a Compare window, press and hold Shift while dropping only one path. This is a handy way to open archive files (see Opening archive files.

You can drop paths into the Select Files or Folders dialog. A typical procedure is to drag and drop the first path into the WinMerge window, and then drag and drop the second path into the Select Files or Folders dialog. When a path is dropped into the Select Files or Folders dialog, it is loaded into either the left or right path field:

Left

If the left field is empty or both path fields already contain paths

Right

If the left path is not empty and the right path is empty

4. Project files

You can save the currently open paths and filters in a project file. Then, you can easily open the project later to compare the same files. Project files are handy if you compare the same files repeatedly.

4.1. Using project files

To use a project file In the WinMerge window, click FileOpen Project. WinMerge reads the paths from the project file. If the project file has two paths, both paths are opened. If only one path is given or one of paths is invalid, WinMerge opens the Select Files or Folders dialog, where you can add or correct the path information. Here are a few things to consider:

  • If you specifiy two project files, the project files themselves are compared.
  • If you specify a project file as the left file but do not specify a right file, the single project file is opened as if you had used the FileOpen Project command.
  • If you specify a project file as the left file and any other file on the right side, the contents of the project file and the other file are compared.

To specify a project file on the command line, simply enter it as a single file path.

4.2. Editing and saving project files

To save a project file, click FileSave Project. The Project File dialog provides fields and options that you can easily edit to build a project file. If a compare window is currently open, the Project File dialog is initialized with values from the current compare; otherwise, you provide the values yourself. To use an existing project, click Open and select a project to load its values (any existing values are overwritten in the dialog).

When you finished editing, click Save to store the file.

Project File dialog

4.3. Project file format

Project files are simple XML files with a .WinMerge extension. For example:

<?xml version='1.0' encoding='UTF-8'?>
<project>
   <paths>
      <left>c:\work\project1</left>
      <left-readonly>1</left-readonly>
      <right>c:\work\project2</right>
      <right-readonly>0</right-readonly>
      <filter>Visual C++ loose</filter>
      <subfolders>0</subfolders>
   </paths>
</project>

A project file contains a paths element that can contain one of each of these elements:

left

Left path to open

left-readonly

1 = Open read only

0 = Open normally

right

Right path to open

right-readonly

1 = Open read only

0 = Open normally

filter

File filter name or list of extensions

subfolders

0 = Subfolders not included

1 = Subfolders included

None of the fields is required, and they can be empty (for example, <left></left> or <left/>).